package and.xunger.com.myfirstdemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

  private ListView listView;
  private String[] data = new String[]{"TabLayout","CoordinatorLayout","ScrollingActivity"};

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView = (ListView) findViewById(R.id.list_view);

    initListView();
  }

  private void initListView() {
    listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, data));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        switch (i) {
          case 0:
            startActivity(new Intent(MainActivity.this, TabLayoutActivity.class));
            break;
          case 1:
            startActivity(new Intent(MainActivity.this,CoordinatorLayoutActivity.class));
            break;
          case 2:
            startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
            break;
        }
      }
    });
  }

}
